package concurrent.demo2;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author: zhenzhong.wang@honeywell.com
 * @Date: 2019/4/1/001 下午 8:09
 */
public class TestLatch {
  public static void main(String[] args) {
    ExecutorService executor = Executors.newCachedThreadPool();
    CountDownLatch latch = new CountDownLatch(3);
    Work work1 = new Work(latch, "张1");
    Work work2 = new Work(latch, "张2");
    Work work3 = new Work(latch, "张3");

    Boss boss = new Boss(latch);

    executor.execute(work1);
    executor.execute(work2);
    executor.execute(work3);
    executor.execute(boss);
    executor.shutdown();
  }
}
